<template>
    <div>
        <r-search :searchForm="searchForm" :searchHandle="searchHandle" :searchData="searchData" />
        <r-table :isSelection="true" :isPagination="true" :tableData="tableData" :tableCols="tableCols" :tablePage="tablePage" @refresh="init()"></r-table>
    </div>
</template>
<script>
export default {
    data() {
        return {
            searchData: {
                id: '',
                moneyStatus: ''
            },
            searchForm: [
                {
                    type: 'input',
                    prop: 'id',
                    placeholder: '订单编号',
                    width: 150
                },
                {
                    type: 'select',
                    prop: 'amountType',
                    placeholder: '资金类型',
                    width: 150,
                    options: [
                        {
                            label: '线上充值',
                            value: '1'
                        },
                        {
                            label: '机器充值',
                            value: '2',
                        },
                        {
                            label: '系统充值',
                            value: '3',
                        },
                        {
                            label: '购物消费',
                            value: '4',
                        },
                        {
                            label: '卡片退卡',
                            value: '5',
                        },
                    ]
                },
            ],
            searchHandle: [
                {
                    label: '搜索',
                    type: 'success',
                    icon: 'el-icon-search',
                    handle: e => this.init()
                },
                {
                    label: '重置',
                    icon: 'el-icon-refresh-right',
                    handle: e => this.searchFromReset()
                }
            ],
            tableData: [
            ],
            tableCols: [
                {
                    label: '订单编号',
                    prop: 'id',
                    // theme: e => e.status ? 'primary' : 'danger', type: "tag",
                },
                {
                    label: '资金类型',
                    prop: 'type',
                    formatter:e=>e.type==1?'支出':e.type==2?'收入':''
                },
                {
                    label: '操作金额',
                    prop: 'changeAmount'
                },
                {
                    label: '备注',
                    prop: 'content',
                },
                {
                    label: '操作时间',
                    prop: 'createdTime',
                    width: 160,
                    formatter: e => e.createdTime&&this.getDeta(+new Date(e.createdTime.replace(/T/g, ' ')))
                },

            ],
            tablePage: { limit: 10, page: 1, total: 0 },
        };
    },
    components: {},
    computed: {},
    methods: {
        async init() {
            this.tablePage.offset = this.tablePage.page

            let param = { ...this.tablePage, ...this.searchData, cardNumber: this.$route.query.id }
            let res = await this.api.icLoglist(param)
            if (res) {
                this.tablePage.total = res.data.total
                this.tableData = res.data.list
            }
        }
    },
    mounted() {
        this.init()
    }
};
</script>
<style scoped lang='scss'>
</style>